<script>
import { getKnowledgeDetail } from "api/knowledge";

export default {
  name: "Detail",
  data() {
    return {
      detail: {},
    };
  },
  created() {
    this.getDetail();
  },
  methods: {
    async getDetail() {
      if (!this.$route.query.id) return;
      const res = await getKnowledgeDetail({ id: this.$route.query.id });
      if (res.code === 200) {
        this.detail = res.data;
      }
    },
  },
};
</script>

<template>
  <div class="container">
    <template v-if="detail.id">
      <div class="text-2xl font-bold font-black">{{ detail.title }}</div>
      <div class="text-gray-400">{{ detail.create_time }}</div>
      <div class="text-gray-600">{{ detail.introduce }}</div>
      <div class="content">
        <div v-html="detail.content"></div>
      </div>
    </template>
    <el-empty v-else class="mt-10" description="暂无数据"></el-empty>
  </div>
</template>

<style scoped lang="scss">
.container {
  width: 694px;
  margin: 0 auto;
  min-height: 65vh;
  background-color: white;
  padding: 20px;
  border-radius: 5px;
  .content{
    font-size: 1.2em;
  }
}
</style>
